#pragma once

#include <vector>
#include <d3d9.h>

namespace rt
{

struct DepthStencilMultiSampleConflict
{
	D3DFORMAT DepthStencilFormat;
	D3DMULTISAMPLE_TYPE MultiSampleType;
};

struct DeviceCombination
{
	UINT AdapterOrdinal;
	D3DDEVTYPE DeviceType;
	D3DFORMAT AdapterFormat;
	D3DFORMAT BackBufferFormat;
	bool Windowed;

	std::vector<D3DFORMAT> DepthStencilFormats;
	std::vector<D3DMULTISAMPLE_TYPE> MultiSampleTypes;
	std::vector<DWORD> MultiSampleQualities;
	std::vector<UINT> PresentationIntervals;
	std::vector<DepthStencilMultiSampleConflict> DepthStencilMultiSampleConflicts;
};

class IDeviceEnumerationFilter
{
public:
	virtual ~IDeviceEnumerationFilter() { }

	virtual bool IsDisplayModeAcceptable(D3DDISPLAYMODE const &mode) = 0;
	virtual bool IsDeviceAcceptable(D3DCAPS9 const &caps,
		D3DFORMAT adapterFormat, D3DFORMAT backBufferFormat, bool windowed) = 0;
};

class IDeviceEnumerator
{
public:
	virtual ~IDeviceEnumerator() { }

	virtual void Enumerate(IDeviceEnumerationFilter *filter) = 0;
	virtual UINT GetNumCombinations() const = 0;
	virtual DeviceCombination const &GetCombination(UINT i) const = 0;
};

}

extern "C" rt::IDeviceEnumerator *rtCreateDeviceEnumerator(IDirect3D9 *d3d);
